#define _CRT_SECURE_NO_WARNINGS  1
#include<stdio.h>
int GetNumberOfK(int* nums, int numsLen, int k)
{
    if (numsLen == 0)
    {
        return 0;
    }
    else
    {
        int i, j;
        for (i = 0; i < numsLen; i++)
        {
            for (j = 0; j < numsLen - i - 1; j++)
            {
                if (nums[j] > nums[j + 1])
                {
                    int tmp;
                    tmp = nums[j];
                    nums[j] = nums[j + 1];
                    nums[j + 1] = tmp;
                }
            }
        }
        int left = 0, right = numsLen - 1, mid = (left + right) / 2;
        while (left < right)
        {
            mid = (left + right) / 2;
            if (nums[mid] > k)
            {
                right = mid - 1;
            }
            else if (nums[mid] < k)
            {
                left = mid + 1;
            }
            else
            {
                break;
            }
        }
        int mid1 = mid;
        while (nums[mid1] == k)
        {
            left = mid1;
            mid1--;
        }
        mid1 = mid;
        while (nums[mid1] == k)
        {
            right = mid1;
            mid1++;
        }
        if (nums[mid] != k)
            return 0;
        return right - left + 1;
    }
}
int main()
{
    int a[] = { 3 };
    int k = 3;
    printf("%d",GetNumberOfK(a, 1, k));
    return 0;
}